require(["common", "coAjax", "hash_routie"], function(jSouper, coAjax, hash_routie) {
	hash_routie.on("collection2", function() {
		//商品收藏
		coAjax.get(appConfig.user.collect_detail, function(result) {
			App.set("$Cache.user.collect_detail", result.result);
		}, function(errorCode, xhr, errorMsg) {
			alert("error", errorMsg);
		});
	});
	App.set("$Event.remove_goods_from_collect", function(e, vm) {
		coAjax["delete"](appConfig.user.collect_remove, {
			goods_id: vm.get("_id")
		}, function(result) {
			alert("成功把商品取消收藏");
			vm.remove();
		}, function(errorCode, xhr, errorMsg) {
			alert("error", errorMsg);
		});
	});

	App.set("$Event.user.collect_goods_add_to_cart", function(e, vm) {
		var cart_item = {
			goods_id: vm.get("_id"),
			num: 1
		};
		coAjax.post(appConfig.user.cart, cart_item, function _get_cart_success(result) {
			alert("success", "添加成功")
		}, function(errorCode, xhr, errorMsg) {
			alert("error", errorMsg);
		});

	});
});